package net.itemzone.framework.webservice.cxf.client;

import org.apache.cxf.frontend.ClientProxyFactoryBean;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;

/** 
 * <p>Title: </p> 
 * <p>Description: </p>
 * <p>Company: 深圳任子行网络技术有限公司</p> 
 * @version 1.00 Apr 13, 2009
 * @author ZhaoJunFei
 *  
 * Modified History: 
 *  
 */
public class SimpleClientFactory {

	private static HttpClientAuthentiacationHandler httpClientAuthentiacationHandler;
	public static <T>T getJaxWsProxyFactory(String address ,Class<T> clazz){
		JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
		factory.setServiceClass(clazz);
		factory.setUsername(httpClientAuthentiacationHandler.getDefaultUserName());
		factory.setPassword(httpClientAuthentiacationHandler.getDefaultPassword());
		factory.setAddress(address);
		T ret = (T)factory.create();
		return ret;
	}
	public static <T>T getClientProxyFactory(String address ,Class<T> clazz){
		ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
		factory.setServiceClass(clazz);
		factory.setUsername(httpClientAuthentiacationHandler.getDefaultUserName());
		factory.setPassword(httpClientAuthentiacationHandler.getDefaultPassword());
		factory.setAddress(address);
		T ret = (T)factory.create();
		return ret;
	}
	
	public void setHttpClientAuthentiacationHandler(
			HttpClientAuthentiacationHandler httpClientAuthentiacationHandler) {
		SimpleClientFactory.httpClientAuthentiacationHandler = httpClientAuthentiacationHandler;
	}

}
